package top.csy8888.ch08.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;
import top.csy8888.ch08.config.RabbitConfig;

/**
 * @author CSY
 * @date 2025 - 10 - 16
 *
 * 死信队列的消费服务
 */
@Service
@Slf4j
public class DeadConsumerService {

    @RabbitListener(queues = RabbitConfig.DEAD_QUEUE_NAME)
    /*@RabbitListener(bindings = @QueueBinding(
            value = @Queue(
                    name = RabbitConfig.DEAD_QUEUE_NAME,
                    durable = "false"
            ),
            exchange = @Exchange(name = RabbitConfig.DEAD_EXCHANGE_NAME,type = ExchangeTypes.DIRECT),
            key = RabbitConfig.DEAD_ROUTING_KEY
    ))*/
    public void receiveDeadLetter(String message){
        log.info("接收到异常消费信息，转人工处理：{}",message);
    }
}
